home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / nitrus.keygen.asm < prev    next >
Encoding:
Assembly Source File  |  1999-07-12  |  1.8 KB  |  74 lines

  1.  
  2. myname db 50 dup(0)
  3. myserial db 100 dup(0)
  4.  
  5.  
  6. serialgencode:      ; starts with length of name in eax
  7.  
  8.     pushad
  9.     lea     ebx,[eax]           ; copy length into ebx
  10.     lea     edi, myserial       ; where i'm going to put the ascii serial
  11.     lea     esi, myname         ; the address of the name, NULL terminated
  12. @serialloop:
  13.     xor     eax,eax
  14.     mov     al, byte ptr [esi]  ; movsb, hehe, get letter from name into EAX
  15.     inc     esi
  16.     test    al,al               ; check for ASCiiZ (NULL)
  17.     jz      finishedcalc
  18.     
  19.     imul    eax,11          ; value=letter*11
  20.  
  21.     cdq
  22.     lea     ecx,[ebx]       ; copy length into ECX
  23.     idiv    ecx             ; value=value / length
  24.     
  25.     ; eax= number for the serial, just need to convert to ascii hex
  26.  
  27.     rol     ax,8            ; my dodgy HEX to ASCii converter
  28.     and     al,0fh
  29.     test    al,al
  30.     je      misshigh    ; skip the high byte of ax, since its only a 1 byte value
  31.     mov     dl,al
  32.     add     dl,30h
  33.     cmp     dl, 39h
  34.     jg      @letter1
  35. done1:
  36.     mov     byte ptr [edi],dl
  37.     inc     edi
  38. misshigh:
  39.     rol     ax,4
  40.  
  41.     and     al,0fh
  42.     mov     dl,al
  43.     add     dl,30h
  44.     cmp     dl, 39h
  45.     jg      @letter2
  46. done2:
  47.     mov     byte ptr [edi],dl
  48.     inc     edi    
  49.     rol     ax,4
  50.  
  51.     and     al,0fh
  52.     mov     dl,al
  53.     add     dl,30h
  54.     cmp     dl, 39h
  55.     jg      @letter3
  56. done3:
  57.     mov     byte ptr [edi],dl
  58.     inc     edi      
  59. skip1:
  60.     mov     byte ptr [edi],0    ; NULL terminate Serial..
  61.     jmp     @serialloop
  62.     
  63. @letter1:               ; change dl to ascii letter 'A-F'
  64.     add     dl, 7
  65.     jmp     done1
  66. @letter2:
  67.     add     dl, 7
  68.     jmp     done2
  69. @letter3:
  70.     add     dl, 7
  71.     jmp     done3
  72. finishedcalc: 
  73.     popad
  74.     ret